package com.itheima;

/*
运行结果: 捕获数组索引越界异常
1. 两个catch中分别捕获NullPointerException，ArrayIndexOutOfBoundsException
2. 捕获异常后，使用输出语句，输出捕获到了哪一个异常对象即可。

 */
public class Demo6 {
    public static void main(String[] args) {
        try {
            String[] arr = {"abc", "bbc", "ccc"};
            System.out.println(arr[10]);
            arr = null;
            System.out.println(arr[0]);
        } catch (NullPointerException e) {
            System.out.println("空指针异常");
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("索引越界异常");
        }
    }
}
